//package com.equipment.management.mqtt;
//
//import org.eclipse.paho.client.mqttv3.*;
//import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
//
//public  class MqttfxClient implements Runnable {
//
//    private static   String Host="tcp://zrd6q7g.mqtt.iot.gz.baidubce.com:1883";
//    private static   String username="zrd6q7g/zhang";
//    private static   String password="RsG907Kzn2I3jL8s";
//    private static   String clientId="hnglajh1";
//    private static   int qos=1;
//    private static   String topic ="point";
//    private static   String content="Hello你好";
//    static MqttClient client=null;
//
//    public static void main(String[] args)throws MqttException {
//        MqttfxClient mqttfxClient=new MqttfxClient();
//        publish();
//        subscribe();
//
//    }
//
//
//
//    public static void publish() throws MqttException{
//
//        client =new MqttClient(Host,clientId);
//        MqttConnectOptions connectOptions=new MqttConnectOptions();
//        connectOptions.setCleanSession(false);
//        connectOptions.setUserName(username);
//        connectOptions.setPassword(password.toCharArray());
//        client.connect(connectOptions);
//        MqttMessage message=new MqttMessage(content.getBytes());
//        message.setQos(qos);
//        client.publish(topic,message);
//        client.disconnect();
//        client.close();
//    }
//    public static String subscribe() throws MqttException{
//        MemoryPersistence persistence=new MemoryPersistence();
//        client=new MqttClient(Host,"13tw188831",persistence);
//        MqttConnectOptions connectOptions=new MqttConnectOptions();
//        connectOptions.setCleanSession(false);
//        connectOptions.setUserName(username);
//        connectOptions.setPassword(password.toCharArray());
//        client.connect(connectOptions);
//        client.setCallback(new MqttCallback() {
//            public void connectionLost(Throwable throwable) {
//
//            }
//
//            public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
//                System.out.println(mqttMessage.toString());
//            }
//
//            public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
//                System.out.println("发送成功");
//            }
//        });
//        client.subscribe("point",1);
//        client.disconnect();
//        client.close();
//        return null;
//    }
//
//    @Override
//    public void run() {
//
//    }
//}
//
